<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<title></title>
		<style>
			*{
				padding: 0;
				margin: 0;
				box-sizing: border-box;
			}
			@media screen and (max-width:900px){
				.b{
					flex-basis: 50%;
				}
			}
			@media screen and (max-width:400px){
				.b{
					flex-basis: 100%;
				}
			}
			
			.a{
				display: flex;
				flex-wrap: wrap;
			}
			.a .b{
				flex-basis: 25%;
				height: 50px;
				background-color: red;
			}
		</style>
	</head>
	<body>
		<div class="a">
			<div class="b">1</div>
			<div class="b">2</div>
			<div class="b">3</div>
			<div class="b">4</div>
		</div>
	</body>
</html>